import { join } from "path";
import { BaseEntity } from "src/baseEntity";
import { Dept } from "src/dept/dept.entity";
import { System } from "src/system/system.entity";
import { UserSys } from "src/user/userSys.entity";
import { resource } from "src/util/path";
import { Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany } from "typeorm";
import { Annread } from "./annread.entity";


@Entity("announcement")
export class Announcement extends BaseEntity {
    @Column()
    title: string

    @ManyToOne(() => UserSys)
    author: UserSys

    @ManyToMany(() => Dept)
    @JoinTable()
    depts: Dept[]

    @ManyToOne(() => System)
    system: System

    @OneToMany(() => Annread, type => type)
    readUsers: Annread[]

    isRead: boolean

    //内容
    context: string
    static getPath(id: number | string) {
        return join(resource, "announcement", `id.json`)
    }
}